###FIRST RUN Study 2 Data Code.R###

####TABLE 3####
table3  <- matrix(NA,16,3)

table3[1,1] <- mean(study2_mi$PROP1_SQ[study2_mi$PROP1_TREAT==0],na.rm=T)
table3[1,2] <- mean(study2_mi$PROP1_SQ[study2_mi$PROP1_TREAT==1],na.rm=T)
table3[1,3] <- table3[1,2] - table3[1,1]
table3[2,1] <- sum(table(study2_mi$PROP1_SQ[study2_mi$PROP1_TREAT==0]))
table3[2,2] <- sum(table(study2_mi$PROP1_SQ[study2_mi$PROP1_TREAT==1]))
table3[2,3] <- as.numeric(t.test(study2_mi$PROP1_SQ[study2_mi$PROP1_TREAT==1],study2_mi$PROP1_SQ[study2_mi$PROP1_TREAT==0])[3])

table3[3,1] <- mean(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0],na.rm=T)
table3[3,2] <- mean(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1],na.rm=T)
table3[3,3] <- table3[3,2] - table3[3,1]
table3[4,1] <- sum(table(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0]))
table3[4,2] <- sum(table(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1]))
table3[4,3] <- as.numeric(t.test(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1],study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0])[3])

table3[5,1] <- mean(study2_mi$PROP3_SQ[study2_mi$PROP3_TREAT==0],na.rm=T)
table3[5,2] <- mean(study2_mi$PROP3_SQ[study2_mi$PROP3_TREAT==1],na.rm=T)
table3[5,3] <- table3[1,2] - table3[1,1]
table3[6,1] <- sum(table(study2_mi$PROP3_SQ[study2_mi$PROP3_TREAT==0]))
table3[6,2] <- sum(table(study2_mi$PROP3_SQ[study2_mi$PROP3_TREAT==1]))
table3[6,3] <- as.numeric(t.test(study2_mi$PROP3_SQ[study2_mi$PROP3_TREAT==1],study2_mi$PROP3_SQ[study2_mi$PROP3_TREAT==0])[3])

table3[7,1] <- mean(study2_mi$PROP4_SQ[study2_mi$PROP4_TREAT==0],na.rm=T)
table3[7,2] <- mean(study2_mi$PROP4_SQ[study2_mi$PROP4_TREAT==1],na.rm=T)
table3[7,3] <- table3[7,2] - table3[7,1]
table3[8,1] <- sum(table(study2_mi$PROP4_SQ[study2_mi$PROP4_TREAT==0]))
table3[8,2] <- sum(table(study2_mi$PROP4_SQ[study2_mi$PROP4_TREAT==1]))
table3[8,3] <- as.numeric(t.test(study2_mi$PROP4_SQ[study2_mi$PROP4_TREAT==1],study2_mi$PROP4_SQ[study2_mi$PROP4_TREAT==0])[3])

table3[9,1] <- mean(study2_mi$PROP5_SQ[study2_mi$PROP5_TREAT==0],na.rm=T)
table3[9,2] <- mean(study2_mi$PROP5_SQ[study2_mi$PROP5_TREAT==1],na.rm=T)
table3[9,3] <- table3[9,2] - table3[9,1]
table3[10,1] <- sum(table(study2_mi$PROP5_SQ[study2_mi$PROP5_TREAT==0]))
table3[10,2] <- sum(table(study2_mi$PROP5_SQ[study2_mi$PROP5_TREAT==1]))
table3[10,3] <- as.numeric(t.test(study2_mi$PROP5_SQ[study2_mi$PROP5_TREAT==1],study2_mi$PROP5_SQ[study2_mi$PROP5_TREAT==0])[3])

table3[11,1] <- mean(study2_mi$PROP6_SQ[study2_mi$PROP6_TREAT==0],na.rm=T)
table3[11,2] <- mean(study2_mi$PROP6_SQ[study2_mi$PROP6_TREAT==1],na.rm=T)
table3[11,3] <- table3[11,2] - table3[11,1]
table3[12,1] <- sum(table(study2_mi$PROP6_SQ[study2_mi$PROP6_TREAT==0]))
table3[12,2] <- sum(table(study2_mi$PROP6_SQ[study2_mi$PROP6_TREAT==1]))
table3[12,3] <- as.numeric(t.test(study2_mi$PROP6_SQ[study2_mi$PROP6_TREAT==1],study2_mi$PROP6_SQ[study2_mi$PROP6_TREAT==0])[3])

table3[13,1] <- mean(study2_ca$PROP30_SQ[study2_ca$PROP30_TREAT==0],na.rm=T)
table3[13,2] <- mean(study2_ca$PROP30_SQ[study2_ca$PROP30_TREAT==1],na.rm=T)
table3[13,3] <- table3[13,2] - table3[13,1]
table3[14,1] <- sum(table(study2_ca$PROP30_SQ[study2_ca$PROP30_TREAT==0]))
table3[14,2] <- sum(table(study2_ca$PROP30_SQ[study2_ca$PROP30_TREAT==1]))
table3[14,3] <- as.numeric(t.test(study2_ca$PROP30_SQ[study2_ca$PROP30_TREAT==1],study2_ca$PROP30_SQ[study2_ca$PROP30_TREAT==0])[3])

table3[15,1] <- mean(study2_ca$PROP34_SQ[study2_ca$PROP34_TREAT==0],na.rm=T)
table3[15,2] <- mean(study2_ca$PROP34_SQ[study2_ca$PROP34_TREAT==1],na.rm=T)
table3[15,3] <- table3[15,2] - table3[15,1]
table3[16,1] <- sum(table(study2_ca$PROP34_SQ[study2_ca$PROP34_TREAT==0]))
table3[16,2] <- sum(table(study2_ca$PROP34_SQ[study2_ca$PROP34_TREAT==1]))
table3[16,3] <- as.numeric(t.test(study2_ca$PROP34_SQ[study2_ca$PROP34_TREAT==1],study2_ca$PROP34_SQ[study2_ca$PROP34_TREAT==0])[3])
###############
